﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace BaoJian.P
{
    public partial class PDetail : System.Web.UI.Page
    {
        private string sid = null;
        /// <summary>
        ///推荐互换的参数ID
        /// </summary>
        private string hid = null;
        /// <summary>
        /// 栏目分类的ID
        /// </summary>
        private string cid = null;
     
        public LYQ.Model.ExchangeProduct model;
        public string CurPosition;

        private  LYQ.BLL.Product bllproduct = new LYQ.BLL.Product();
        public LYQ.Model.Product modeProduct = null;
        public DataTable dt;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
               try
               {
                  sid = HttpContext.Current.Request.QueryString["SID"];
                  hid = HttpContext.Current.Request.QueryString["hid"];
                  cid = HttpContext.Current.Request.QueryString["cid"];



                  if (hid == null && cid == null)
                  {
                     Page.Response.Redirect("../Error.aspx");
                  }

                  if (hid != null) //推荐栏目
                  {
                     LYQ.BLL.SysObj sysbll = new LYQ.BLL.SysObj();
                     LYQ.Model.SysObj sysmodel = sysbll.GetModel(hid);
                     CurPosition = sysmodel.OName;
                  }
                  else if (cid != null) //普通分类
                  {
                     LYQ.BLL.Class classbll = new LYQ.BLL.Class();
                     string sql = string.Format("SubCatalogID = '{0}'", cid);
                     LYQ.Model.Class cidmodel = classbll.GetModelList(sql)[0];
                     CurPosition = cidmodel.SubCatalogName;
                  }
               }
               catch { }
              
                //string SQL = string.Format("SELECT top 1 FROM [VExchangeProducts] WHERE sid={0}",sid);
                



              /*  if (sid != null)
                {
                    bll = new LYQ.BLL.ExchangeProduct();
                  //  model = bll.GetModel(sid);                  
                    model.BrowserCount += 1;
                    bll.Update(model); 
                   // model.ImagePath = model.ImagePath.Replace("~", "");            

                    //当前位置
                   //  CurPosition = "<a href=\"plist.aspx?c="+model.PCatalog+"\">"+model.PCatalogName+"</a>";
                    //得到产品信息
                }
                else if (hid != null)
                {                  
                   //  LYQ.BLL.SysObj objbll = new LYQ.BLL.SysObj();
                   //  LYQ.Model.SysObj objmodel = objbll.GetModel(hcolumnid);                  
                   //  CurPosition = "<a href=\"clist.aspx?c="+objmodel.OID+"\">"+objmodel.OName+"</a>";
                     
                   //  bll = new LYQ.BLL.ExchangeProduct();
                   ////  model = bll.GetModel(hid);                  
                   //  model.BrowserCount += 1;
                   //  bll.Update(model);
                   // // model.ImagePath = model.ImagePath.Replace("~", "");
                }*/
                //else
                //{
                //    Page.Response.Redirect("../Error.aspx");
                //}

                //dt = bllproduct.GetList("Name like '%" + model.PName + "%' ").Tables[0];          
            }
        }
       
    }
}
